package org.samoji.sji.profTokenizer;

import java.math.BigDecimal;

public class Token {

    private final Type type;
    private final BigDecimal num;
    private final String name;

    Token(Type type, BigDecimal num, String name) {
        this.type = type;
        this.num = num;
        this.name = name;
    }

    Token(Type type) {
        this(type, null, null);
    }

    public enum Type {
        Eos,
        Num, Id,
        Plus, Minus, Times, Div, Mod, Pow,
        Becomes,
        PlusBecomes, MinusBecomes, TimesBecomes, DivBecomes, ModBecomes, PowBecomes,
        OpenParen, CloseParen, Semicolon,
        Unknown,
    }

    public Type type() {
        return type;
    }

    public String name() {
        return name;
    }

    public BigDecimal num() {
        return num;
    }
    
    @Override
    public String toString() {
        switch (type()) {
        case Num: return type() + "[" + num() + "]";
        case Id: return type() + "[" + name() + "]";
        default: return type().toString();
        }
    }
}
